//
//  HDLViewController.swift
//  PassValueDemo
//
//  Created by MAC on 2020/8/20.
//  Copyright © 2020 MAC. All rights reserved.
//

import UIKit
//MARK:- 页面 1
class HDLViewController: UIViewController {
    
    var labels = UILabel()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        //跳转下级页面
        let ymBtn_01 = UIButton()
        ymBtn_01.frame = CGRect(x: 50, y: 130, width: 120, height: 50)
        ymBtn_01.setTitle("跳转下级页面", for: .normal)
        ymBtn_01.backgroundColor = .brown
        ymBtn_01.tag = 10001
        ymBtn_01.addTarget(self, action: #selector(tiaozhuanyemianclick(sender:)), for: .touchUpInside)
        view.addSubview(ymBtn_01)
        
        //接收传值的标签
        labels.frame = CGRect(x: 50, y: (ymBtn_01.frame.origin.y+ymBtn_01.frame.size.height)+50, width: view.frame.size.width-100, height: 50)
        labels.backgroundColor = .darkGray
        labels.textColor = .white
        view.addSubview(labels)
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        //接收传值
        self.labels.text = HYSingle.sharedInstance.sendValue
    }
    
    @objc func tiaozhuanyemianclick(sender:UIButton){
        //声明变量名，并初始化类名
        let aDLVC = ADLViewController.init()
        aDLVC.title = "页面 2"
        aDLVC.view.backgroundColor = UIColor.init(named: "bgColor")
        //跳转下级页面
        navigationController?.pushViewController(aDLVC, animated: true)
        
    }
}
